<template>
<div>
  <p>姓名:<input type="text" v-model="form.name"></p>
  <p>用户名:<input type="text" v-model="form.username"></p>
  <p>密码:<input type="text" v-model="form.password"></p>
  <p>
    <select name="" id="" v-model="form.cla">
    <option :value="i.id" v-for="i in classlist">{{i.name}}</option>
    </select>
  </p>
  <button @click="reg">提交</button>
</div>
</template>

<script>
export default {
  name: "work_reg",
  data(){
    return{
      form:{},
      classlist:{},
    }
  },
  methods:{
    get_classlist(){
      this.$axios.get('users/calssm/')
      .then(res=>{
        this.classlist=res.data.list
      })
    },
    reg(){
      this.$axios.post('users/reg/',this.form)
      .then(res=>{
        if(res.data.code==200){
          localStorage.setItem('id',res.data.id) //保存id
          localStorage.setItem('name',res.data.name) //保存name
          this.$router.push({'path':'/work_student'})
        }
      })
    },
  },
  mounted() {
    this.get_classlist()
  }
}
</script>

<style scoped>

</style>
